import { GameLogic } from "../../../Runtime/GameLogic";
import { StateTypeEnum } from "../../../common/Enum";
import BTAction from "../../Base/BTAction";
import Boss1Tree from "../Tree/Boss1Tree";

export default class ActionRandomRun extends BTAction {

    constructor(
        private tree: Boss1Tree,
    ) {
        super()
    }

    onStart(): void {
        const enemy = this.tree.enemy
        enemy.state = StateTypeEnum.run
        if (
            !enemy.targetPos ||
            (Math.abs(enemy.targetPos.x - enemy.position.x) < 1 && Math.abs(enemy.targetPos.y - enemy.position.y) < 1)
        ) {
            enemy.targetPos = GameLogic.Ins.getRandomPos()
        }
        super.onStart()
    }

    onEnd(): void {
        super.onEnd()
    }

}